package com.SMP.service.class_room;

import com.SMP.dao.LessonsMapper;
import com.SMP.model.Lessons;
import com.SMP.model.LessonsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class LessonsService {
    @Autowired
    LessonsMapper lessonsMapper;
    /**
     * @author TSY
   //  * @param 查询所有课节
     */
    public List<Lessons> getAllLes() {

        return lessonsMapper.selectByExample(null);
    }
    /**
     * @author TSY
    // * @param 添加课节
     */
    public int  addLessons(Lessons lessons) {

        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddss");//设置日期格式

        df.format(new Date());//一账户创建时间
        return lessonsMapper.insertSelective(lessons);
    }
    /**
     * @author TSY
    // * @param 按照Id查询课节
     */
    public Lessons getLessons(String lessonsId) {

        Lessons lessons = lessonsMapper.selectByPrimaryKey(lessonsId);
        return lessons;
    }
    /**
     * @author TSY
    // * @param 按照Id查询课节
     */
    public Lessons selLessonByName(String lessonsName) {

        Lessons lessons = lessonsMapper.selectBylessonName(lessonsName);
        return lessons;
    }
    /**
     * @author TSY
    // * @param 修改课节
     */
    public int updateLessons(Lessons lessons) {
        return lessonsMapper.updateByPrimaryKeySelective(lessons);
    }
    /**
     * @author TSY
    // * @param 删除课节(假删）
     */
    public int  deleteLessons(String lessonsId) {

        //lessonsMapper.deleteByPrimaryKey(lessonsId);
        Lessons lessons =lessonsMapper.selectByPrimaryKey(lessonsId);
        lessons.setStandby1("0");
        return lessonsMapper.updateByPrimaryKey(lessons);
    }

}
